package com.gla.giliair.util;

import java.util.regex.Pattern;

/**
 * @Description:
 * @Author: Yingtian qian
 * @Date: 2021/8/23 15:37
 */
public class PatternUtil {

    public static boolean isEmail(String emailString) {
        //邮箱格式xxxxx@xxxxx.xxx
        String regex = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
        if (emailString.matches(regex)) {
            return true;
        }
        return false;
    }

    public static boolean isPhone(String phoneString) {
        //手机号格式
        String regex = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$";
        if (phoneString.matches(regex)) {
            return true;
        }
        return false;
    }

    public static boolean isIdentity(String identityString) {
        //身份证格式
        String regex = "^([1-6][1-9]|50)\\d{4}(18|19|20)\\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
        if (identityString.matches(regex)) {
            return true;
        }
        return false;
    }
}
